package com.kaibes.module.user.safe;

import java.sql.SQLException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.kaibes.module.user.UserService;
import com.kaibes.orm.core.listener.InsertListener;
import com.kaibes.orm.curd.Insert;
import com.kaibes.orm.spring.OrmListener;

@OrmListener(service = UserService.class)
public class UserInsertListener4Safe implements InsertListener<Integer> {
    
    @Autowired
    private UserSafeService userSafeService;

    @Override
    public void afterInsert(Insert insert, List<Integer> ids) throws SQLException {
        UserSafeInsert userSafe = new UserSafeInsert();
        userSafe.setUserId(ids.get(0).intValue());
        userSafeService.save(userSafe);
    }
}
